{% load ratio %}
{% load get_attr %}
{% load show_diff_title %}
<form id="batch-manage-form" action="" method="post">
    <table class="table table-bordered table-striped table-hover">
        <thead>
            <tr>
                <th>{% if user_session.user_role >= 2 %}<input type="checkbox" id="select-all">&nbsp;&nbsp;题号{% endif %}</th>
                <th>题目名称</th>
                <th>发布者</th>
                <th>难度</th>
                <th>全站正确率</th>
                <th>我的正确率</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
        {% for problem in problems %}
        <tr class="problem_items {{ used_problems | get_attr:problem.id }}" data-id="{{ problem.id }}">
            <td>
                {% if user_session.user_role >= 2 %}<input type="checkbox" class="batch-manage-checkbox" value="{{ problem.id }}" name="problem_ids"/>&nbsp;{% endif %}
                {{ problem.id }}
            </td>
            <td>
                <a href="{% url "problem_show" problem.id %}" target="_blank">{{ problem.title }}</a>
                {% if not problem.is_show %}
                <span class="glyphicon glyphicon-eye-close"></span>
                {% endif %}
                {% if problem.pause_judge %}<span class="glyphicon glyphicon-pause" title="评测暂停"></span>{% endif %}
            </td>
            <td><a href="{% url "account_space" problem.author.id %}" target="_blank">{{ problem.author.nickname }}</a></td>
            <td>{{ problem.difficulty | show_diff_title }}</td>
            <td>
                {{ problem.judge_ratio }}
            </td>
            <td>
                {% if problem.id in problem_visited %}
                {{ problem_visited | get_attr:problem.id }}
                {% endif %}
            </td>
            <td>
                {% if user_session.user_role >= 2 %}
                    <div class="btn-group dropdown">
                        <a href="javascript:void(0)" class="label label-warning dropdown-toggle" data-toggle="dropdown">
                            <span class="glyphicon glyphicon-wrench"></span>&nbsp;管理题目&nbsp;<span class="caret"></span>
                        </a>
                        <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                            {% if asgn != None %}
                                <li><a href="javascript:void(0)" class="asgn_problem_setting" data-id="{{ asgn_problems | get_attr:problem.id | get_attr:"id" }}">题目设置</a></li>
                                <li class="divider"></li>
                            {% endif %}
                            <li><a href="{% url 'problem_mgr_modify_problem' problem.id %}#info">编辑题目</a></li>
                            <li><a href="{% url 'problem_mgr_modify_problem' problem.id %}#demo-code">示例代码</a></li>
                            <li><a href="{% url 'problem_mgr_modify_problem' problem.id %}#test-data">测试数据</a></li>
                            <li><a href="{% url 'problem_mgr_modify_problem' problem.id %}#classify">题目分类</a></li>
                            <li class="divider"></li>
                            {% if asgn == None %}
                            <li><a href="{% url 'problem_mgr_modify_problem' problem.id %}#delete" target="_blank">删除题目</a></li>
                            {% else %}
                            <li><a href="javascript:void(0)" class="remove_asgn_problem" data-id="{{ asgn_problems | get_attr:problem.id | get_attr:"id" }}">移除题目</a></li>
                            {% endif %}
                        </ul>
                    </div>
                {% endif %}
                <a href="{% url 'problem_show' problem.id %}#submit" target="_blank" class="label label-primary">提交代码</a>&nbsp;
                <a href="{% url 'problem_show' problem.id %}#history" target="_blank" class="label label-success">评测历史</a>
            </td>
        </tr>
        <tr class="problem_detail_panel">
            <td colspan="6">
            <span id="problem_detail_area_{{ problem.id }}"></span><br />

            </td>
        </tr>
        {% empty %}
            <tr>
                <td colspan="6">哎呀，还没有题目呢！</td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
</form>

